home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1191 / 1191.xpi / chrome / reminderfox.jar / content / reminderfox / mail / addContact2Reminder.js next >
Text File  |  2009-12-02  |  22KB  |  655 lines

  1. // ++ IMPORTANT NOTICE --     
  2. // 
  3. // +++++++       This file is UTF-8. 
  4. // +++++++       Please adjust you text editor prior to saving any changes!
  5. //
  6. // ++ IMPORTANT NOTICE --  
  7.  
  8. //https://developer.mozilla.org/en/nsIAbCard%2f%2fThunderbird3
  9.  
  10. /**
  11.  *   add a Reminder for a selected 'Contact' of the TB / ADDRESSBOOK
  12.  *
  13.  *  //gW - Guenter Wahl ...    vers. 01. August 2007 15:03
  14.  
  15.         The ABcard items added to the output (reminder.notes) are 
  16.         configured with a 'rmFx_cardItems'-string 
  17.         which is read from/written to the 'rmFx.abCardItems' TB-prefs.
  18.         
  19.         Valid items are all addressbook/card items, but only the following 
  20.         have a 'locale' entry. For the others their item name is displayed.
  21.         
  22.             - LabelContact
  23.                 - DisplayName    
  24.                 - NickName
  25.                 - PrimaryEmail
  26.                 - SecondEmail
  27.                 - ScreenName
  28.                 
  29.             - LabelHome
  30.                 - HomeAddress    
  31.                     
  32.             - LabelWork
  33.                 - WorkAddress    
  34.     
  35.             - LabelPhone
  36.                 - CellularNumber    
  37.                 - FaxNumber            
  38.                 - PagerNumber
  39.                 
  40.             - LabelOther
  41.                 - Costom1 .. 4
  42.                 
  43.  
  44.         'rmFx_cardItems'-string interpretation:
  45.  
  46.             !item                generates 'nameString' tab 'dataOfNameString'
  47.             item                generates 'dataOfNameString' only
  48.             item,[!]item        items separated with comma are generated as
  49.                                 data output on same line separated by space                                
  50.             ;                    delimiter for generating a CR for the output
  51.             //                    an entry beginning with // is treated as comment 
  52.                                 which is not written to the output
  53.                     
  54.             - Items containing a substring of 'Label' are interpreted as header lines.    
  55.             
  56.             - Items with a leading 'X' are skipped for output.
  57.               This is a easy way to skip them, but hold them at the 
  58.               standard place in the default 'rmFx_cardItems'-String.    
  59.  
  60.             - The 'Category' items need not to be added to the
  61.               interpretation string, it's added to rmFx-field 'Categories'
  62.  
  63.             - 'Custom1..4'-item labels
  64.                 With the extension "MoreColsForAddressBook"
  65.                     https://nic-nac-project.org/~kaosmos/morecols-en.html
  66.                 installed, the 'labels' can be set individually and are 
  67.                 stored in the prefs.js parameters  
  68.                 "morecols.custom"+num+".label"  (num= 1...4)
  69.                 Those settings are read if xpi is installed.
  70.  
  71.     */
  72.  
  73.     var rmFx_cardItemsUS = "// US version;"
  74.                     + "LabelContact;"
  75.                         + "!DisplayName;"
  76.                         + "X!LastName,XFirstName;"
  77.                         + "!PrimaryEmail,XSecondEmail;"
  78.             
  79.                     + "LabelPhone;"                    
  80.                         + "!HomePhone,!FaxNumber;"
  81.                         + "!WorkPhone;"
  82.                         + "!CellularNumber;"
  83.                     
  84.                     + "LabelHome;"    
  85.                         + "HomeAddress,HomeAddress2;"
  86.                         + "HomeCity,HomeState,HomeZipCode;"            
  87.                         + "HomeCountry;"                
  88.             
  89.                     + "LabelWork;"    
  90.                         + "JobTitle;"
  91.                         + "Company,Department;"
  92.                         + "WorkAddress,WorkAddress2;"
  93.                         + "WorkCity,WorkState,WorkZipCode;"            
  94.                         + "WorkCountry;"                
  95.             
  96.                     + "LabelOther;"    
  97.                         + "!Custom1,!Custom2;"
  98.                         + "!Custom3;!Custom4;"
  99.                     //    + "!AnniversaryYear,AnniversaryMonth,AnniversaryDay;"
  100.                         + "X!BirthYear,XBirthMonth,XBirthDay;"
  101.                     
  102.                     ;  // semikolon terminates 'rmFx_cardItems' !
  103.  
  104.  
  105.     var rmFx_cardItemsEU = "// European version;"
  106.                     + "LabelContact;"
  107.                         + "!DisplayName;"
  108.                         + "!LastName,FirstName;"
  109.                         + "!PrimaryEmail,SecondEmail;"
  110.             
  111.                     + "LabelPhone;"                    
  112.                         + "!HomePhone,!FaxNumber;"
  113.                         + "!WorkPhone;"
  114.                         + "!CellularNumber;"
  115.                     
  116.                     + "LabelHome;"    
  117.                         + "!HomeAddress,HomeAddress2;"
  118.                         + "!HomeZipCode,HomeCity;"            
  119.                         + "!HomeCountry,!HomeState;"                
  120.             
  121.                     + "LabelWork;"    
  122.                         + "JobTitle;"
  123.                         + "!Company,Department;"
  124.                         + "!WorkAddress,WorkAddress2;"
  125.                         + "!WorkCity,WorkZipCode;"            
  126.                         + "!WorkCountry,!WorkState;"                
  127.             
  128.                     + "LabelOther;"    
  129.                         + "!Custom1,!Custom2;"
  130.                         + "!Custom3;!Custom4;"
  131.                     //    + "!AnniversaryYear,AnniversaryMonth,AnniversaryDay;"
  132.                         + "X!BirthYear,XBirthMonth,XBirthDay;"
  133.                     
  134.                     ;  // semikolon terminates 'rmFx_cardItems' !
  135.  
  136.     var rmFx_cardItems;        // this contain the active cardItem set
  137.  
  138.     var rmFx_ABprop = "rf.contacts.";
  139.     var rmFx_ABerrMsg = "addContact2Reminder Error!\nConfiguration item not valid: ";
  140.     var rmFx_ABerrMsg2 = "addContact2Reminder Error!\nItem naming not valid for:  ";
  141.     
  142.     var rmFx_personalABURI = 'moz-abmdbdirectory://abook.mab';
  143.     var rmFx_collectedAABURI = 'moz-abmdbdirectory://history.mab';
  144.     var rmFx_selectedABURI = null;
  145.     var rmFx_cDirectory = '';
  146.     var rmFx_cCard;
  147.     var rmFx_ABbundle = document.getElementById("bundle_addressBook");
  148.  
  149. /*
  150.  * 
  151.  * /messenger/addressbook/abCardOverlay.js/
  152.  * 
  153.  * function AbEditSelectedCard()
  154.     {
  155.           AbEditCard(GetSelectedCard());
  156.     }
  157.  
  158.         --> goEditCardDialog(GetSelectedDirectory(), card);
  159.         
  160.         ondialogaccept="return EditCardOKButton();">
  161.         
  162.         siehe 
  163.  *        function InitEditCard() 
  164.  *        --> gEditCard
  165.  *
  166.  *
  167.  *
  168.  */    
  169.     
  170.     
  171.     
  172. function reminderFox_addReminder4Contact(op){
  173.  
  174.     //    --- get the Contact info
  175.     rmFx_selectedABURI = GetSelectedDirectory();
  176.     rmFx_cDirectory = GetDirectoryFromURI(rmFx_selectedABURI).dirName;
  177.  
  178.     if (rmFx_cDirectory.isMailList)  { return;} // terminate if on 'List'        
  179.  
  180.     switch (op) {
  181.     
  182.     case "Reminder":  { // this is to set a reminder from a selected card 
  183.         var rmFx_cCard = GetSelectedCard();    
  184.         
  185.         // --- setup the reminder -----
  186.         var time = new Date();
  187.         //time.getTime();
  188.         var timeString = reminderFox_mail_getTimeString( time );
  189.  
  190.         var dateVariableString;
  191.         try { dateVariableString = reminderFox_getUnicodePref(REMINDER_FOX_PREF + "." + REMINDER_FOX_LIST_DATE_LABEL);
  192.             } catch(e) {}           
  193.         var remFoxDate =reminderFox_getDateVariable( null, time, dateVariableString ) + "  " + timeString;
  194.         
  195.         var newDate = new Date();
  196.         newDate.setDate( newDate.getDate() + 1 );  // default to using tomorrow's date for reminder
  197.  
  198.         var reminderId = reminderFox_generateUniqueReminderId( newDate );
  199.  
  200.         if (gRmFx_AB3) {  // if TB/AB3 then add an "UUID" element to the card
  201.                         
  202.             // alert ("we are in reminderFox_addReminder4Contact ... ")
  203.             // rmFx_cCard.setProperty("UUID", reminderId);
  204.         }
  205.         
  206.         
  207.         var remFoxSummary  = "[" + rmFx_itemName ("LabelContact") + "] " 
  208.                 + rmFx_cCardItem(rmFx_cCard, "DisplayName");
  209.  
  210.         var    newReminderToBeAdded     = new ReminderFoxEvent( reminderId, newDate, remFoxSummary );
  211.  
  212.         newReminderToBeAdded.extraInfo = "X-REMINDERFOX-CONTACT:"
  213.             + rmFx_selectedABURI + "::" + rmFx_cDirectory 
  214.             + "::" + rmFx_cCard.displayName;
  215.         
  216.         var cNotes = ""; 
  217.         
  218.         var custItems ="";
  219.         var labelStr = "";
  220.         
  221.         // +++++ read  all card-items to be added +++++
  222.         var rmFx_cardItems = rmFx_readABcardPref();       /* -- get values  -- */                                 
  223.  
  224.         var cardItems = rmFx_cardItems.split(";");
  225.         
  226.         for (var i=0;i<cardItems.length;i++) { 
  227.  
  228.             var anyValue = false;    
  229.             var currentLine = cardItems[i]; 
  230.             
  231.             if (cardItems[i].indexOf( "Label" ) != -1 ) {
  232.                 if (cardItems[i].charAt(0) != "X") {
  233.                     labelStr = "";
  234.                     if ( cNotes.length > 0 ) { // don't add newline for first entry
  235.                         labelStr += "\n";
  236.                     }
  237.                     labelStr += rmFx_itemName (cardItems[i]) + ":\n";
  238.                 }
  239.             } else {
  240.                 if ((currentLine != "") 
  241.                   && (currentLine.substring(0,2) != "//")) {
  242.                   
  243.                       var usAdr= false;
  244.                       if (    currentLine.indexOf("WorkCity,WorkState") != -1  ||
  245.                                currentLine.indexOf("HomeCity,HomeState") != -1  
  246.                           ) usAdr = true;
  247.                   
  248.                     var cItems = currentLine.split(",");  
  249.                     
  250.                     for (var j=0; j<cItems.length; j++) { /* one item */
  251.                         var namString = cItems[j]; 
  252.                 
  253.                         //  process  cardItem 
  254.                         if (namString.charAt(0) == "!") {
  255.                             // this needs to fetch the namString
  256.                             var iName = namString.substring(1);
  257.                         } else {iName = namString;} 
  258.                         
  259.                         if (iName == "HomeWebPage") iName ="WebPage1";
  260.                         if (iName == "WorkWebPage") iName ="WebPage2";
  261.                         var iname = iName.substring(0,1).toLowerCase() + iName.substring(1);
  262.  
  263.                         if (iname.charAt(0) != "x") {
  264.                             var thisItem = rmFx_cCardItem(rmFx_cCard, iName);
  265.                             
  266.                             if (iName.indexOf("Custom") != -1) {
  267.                                 if ( thisItem != -1 && thisItem != "") {
  268.                                     cNotes +=  labelStr + "    " + rmFx_itemName(iName) + " : " 
  269.                                                         + thisItem + "; "
  270.                                     anyValue = true;
  271.                                     labelStr = "";
  272.                                 }
  273.                             } else {
  274.                                 if (namString.charAt(0) == "!") {
  275.                                     if ( thisItem != -1 && thisItem != "") {                                
  276.                                         cNotes += labelStr + "    " + rmFx_itemName(iName) + ":\t";
  277.                                         anyValue = true;
  278.                                         labelStr = "";
  279.                                     }
  280.                                 }        
  281.                                 if ( thisItem != -1 && thisItem != "")  {
  282.                                     if (labelStr != "" && thisItem != "") {
  283.                                         cNotes += labelStr;
  284.                                         labelStr = "";
  285.                                     }
  286.                                     if (anyValue == false)     cNotes +=  "    ";                                
  287.                                     
  288.                                     cNotes +=  thisItem ; 
  289.                                     if (usAdr == false) { cNotes +=  "   ";}
  290.                                         else {  cNotes +=  ",  "; 
  291.                                     } usAdr = false;
  292.                                     anyValue = true;
  293.                                 }
  294.                             } 
  295.                         }
  296.                     }
  297.                 }
  298.                 if (anyValue == true) cNotes += "\n";
  299.             }
  300.         }    
  301.  
  302.         cNotes += '\n[' + rmFx_cDirectory  +  ']';  // add from where we got the address from
  303.         newReminderToBeAdded.notes = cNotes;    
  304.         if (custItems != "") newReminderToBeAdded.notes  += "\n" + custItems + "\n";    
  305.  
  306.         // --- add ABcard-items to rmFx-fields ---
  307.         
  308.         // add address to 'Location' for search with Google Maps  
  309.             var workAddr ="";
  310.             
  311.             var w = rmFx_cCardItem(rmFx_cCard, "WorkAddress");     if (w != "") workAddr += w + " ";
  312.             var w = rmFx_cCardItem(rmFx_cCard, "WorkAddress2"); if (w != "") workAddr += w + " ";
  313.             var w = rmFx_cCardItem(rmFx_cCard, "WorkCity");     if (w != "") workAddr += w + " ";
  314.             var w = rmFx_cCardItem(rmFx_cCard, "WorkAddress");     if (w != "") workAddr += w + " ";
  315.             var w = rmFx_cCardItem(rmFx_cCard, "WorkState");     if (w != "") workAddr += w + " ";
  316.             var w = rmFx_cCardItem(rmFx_cCard, "WorkZipCode");     if (w != "") workAddr += w + " ";
  317.             var w = rmFx_cCardItem(rmFx_cCard, "WorkCountry");     if (w != "") workAddr += w + " ";
  318.  
  319.             var locAddr ="";
  320.             var w = rmFx_cCardItem(rmFx_cCard, "HomeAddress");     if (w != "") locAddr += w + " ";
  321.             var w = rmFx_cCardItem(rmFx_cCard, "HomeAddress2"); if (w != "") locAddr += w + " ";
  322.             var w = rmFx_cCardItem(rmFx_cCard, "HomeCity");     if (w != "") locAddr += w + " ";
  323.             var w = rmFx_cCardItem(rmFx_cCard, "HomeState");     if (w != "") locAddr += w + " ";
  324.             var w = rmFx_cCardItem(rmFx_cCard, "HomeZipCode");     if (w != "") locAddr += w + " ";
  325.             var w = rmFx_cCardItem(rmFx_cCard, "HomeCountry");     if (w != "") locAddr += w + " ";
  326.  
  327.             if (locAddr == null || locAddr == "") locAddr = workAddr;
  328.             
  329.     //  .location does NOT accept local chars like ├â┬û in 'K├â┬ûLN'  ==> so normalize the string
  330.             newReminderToBeAdded.location = rmFx_normalizeNameString(locAddr);
  331.         
  332.         var cItem = rmFx_cCard.primaryEmail;
  333.         if (cItem != "") newReminderToBeAdded.url = "mailto" + ":" + cItem ;    
  334.  
  335.         cItem = rmFx_cCardItem(rmFx_cCard, "Category");    
  336.         if (cItem != "") newReminderToBeAdded.categories =  rmFx_cCard.category; 
  337.  
  338. /*        if (rmFx_cCard["birthYear"] != "")  {
  339.             newReminderToBeAdded.summary += '   <' + rmFx_cCard["birthYear"] + '>';
  340.         }
  341. */
  342.         rmFx_writeABcardPref();
  343.         
  344.         //  .... and go to display it ....
  345.         var added = reminderFox_addReminderHeadlessly( newReminderToBeAdded );        
  346.     
  347.     }
  348.     case "Copy": {  // copy mailadr of selected cards to clipboard
  349.             //    with mailName <mailadr@xxx.yy>, etc
  350.         var rmFx_Cards = GetSelectedAbCards();
  351.         var xAttendees="";
  352.         for (var n=0; n < rmFx_Cards.length; n++) {
  353.             xAttendees += rmFx_Cards[n].lastName + rmFx_Cards[n].firstName
  354.             + "<" + rmFx_Cards[n].primaryEmail + ">,";
  355.         }
  356.         // del last comma    
  357.         xAttendees = xAttendees.substring(0, xAttendees.length-1)    
  358.         rmFx_abookMini();  
  359.         rmFxUtil.copytoClipboard(xAttendees);
  360.         rmFx_insertAttendees(xAttendees);
  361.         
  362.         return;
  363.     }
  364.     
  365.     } // switch
  366. }
  367.  
  368.  
  369. function rmFx_cCardItem(rmFx_cCard,iName) {
  370. // ---------------- get item Value or set to -1 if invalid " 
  371.         
  372.     try {    
  373.         if(!gRmFx_AB3) {
  374.             iName = iName.substring(0,1).toLowerCase() + iName.substring(1); 
  375.             !rmFx_cCard[iName].length;
  376.             return rmFx_cCard[iName];
  377.         } else {
  378.             var iValue = rmFx_cCard.getProperty(iName, "");
  379.             return iValue;
  380.         }
  381.  
  382.     }     catch(ex) {
  383.         alert(  rmFx_ABerrMsg + "\n1: " + iName);                 
  384.         reminderFox_logMessageLevel(rmFx_ABerrMsg + iName, 2);
  385.         return -1;
  386.     }                        
  387. }
  388.  
  389.  
  390.  
  391. function rmFx_itemName (namItem) {
  392. /* ---------- access the properties ... if relevant  -------------
  393. */
  394. try {
  395.     // .... access 'address.properties'    
  396.     if (  namItem == "DisplayName" ||
  397.           namItem == "NickName"       ||
  398.           namItem == "PrimaryEmail"||
  399.           namItem == "SecondEmail" ||
  400.           namItem == "ScreenName"        )                 
  401.         return rmFx_ABbundle.getString("property"+namItem);                 
  402.       
  403.       
  404.     if (  namItem == "LabelContact" || namItem == "HomeAddress"         )      
  405.         return reminderFox_getBundle().getString(rmFx_ABprop+namItem);
  406.  
  407.     if (  namItem.indexOf("Label") != -1)     
  408.         return rmFx_ABbundle.getString("heading"+ namItem.substring(5)); 
  409.  
  410.     if (  namItem.indexOf("Number") != -1)     
  411.         return rmFx_ABbundle.getString("property"+ namItem.substring(0,namItem.indexOf("N"))); 
  412.  
  413.     
  414.     // ... access morecols.properties  ... if there else addressbook.p
  415.     if (  namItem.indexOf("Custom") != -1)
  416.         return rmFx_getCustomLabel (namItem);
  417.  
  418.     // ... now no entries ... need to set it here (without 'locale' translation)
  419.     if (  namItem.indexOf("Name") != -1 )    return namItem;
  420.  
  421.     if (  namItem == "JobTitle"            )    return "Job";
  422.     if (  namItem == "Department"        )    return "Department";
  423.     if (  namItem == "Company"            )    return "Company";
  424.               
  425.     if (  namItem == "HomeWebPage" || 
  426.           namItem == "WorkWebPage"        )    return "WebPage";
  427.     
  428.     if (  namItem.indexOf("Address2") != -1) return "";
  429.  
  430.     //  ... delete 'Phone'  from item-name and return it 
  431.     if (    namItem.indexOf("Phone") != -1)
  432.         return namItem.substring(0,4); 
  433.  
  434.     // ... delete 'Work' or 'Home' from item-name and return it  
  435.     if (    (namItem.indexOf("Work") != -1)
  436.         ||  (namItem.indexOf("Home") != -1) )
  437.         return namItem.substring(4); 
  438.  
  439.  
  440.     }
  441.     catch(ex) {
  442.         // alert(  rmFx_ABerrMsg2 + "\n2: " + namItem);                 
  443.         reminderFox_logMessageLevel(rmFx_ABerrMsg2 + namItem, 2);
  444.     }
  445.                 
  446.     return namItem;
  447. }
  448.  
  449.  
  450.  
  451. function rmFx_getCustomLabel (iName) {
  452. // ---------- work with Custom 1..4 individual entries  -------------
  453.  
  454.     var cLabel="";
  455.     var moreColsPrefs = Components.classes["@mozilla.org/preferences-service;1"]
  456.             .getService(Components.interfaces.nsIPrefBranch);
  457.             
  458.     var cLabelid =     "morecols." 
  459.                 + iName.substring(0,1).toLowerCase() + iName.substring(1)+".label";    
  460.     try { 
  461.         cLabel = moreColsPrefs.getComplexValue
  462.             (cLabelid, Components.interfaces.nsISupportsString).data;
  463.        } catch(e) { 
  464.            cLabel = "Custom " + iName.substring(6,7);
  465.        }
  466.            
  467.        return cLabel;
  468. }
  469.  
  470. function rmFx_readABcardPref() {
  471. // ------------------------------------------------ READ  PREFS
  472.     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  473.             .getService(Components.interfaces.nsIPrefBranch);
  474.  
  475.     var abCardPrefVersion = "US";
  476.     try { abCardPrefVersion = prefService.getCharPref
  477.             ("rmFx.abCardItems.version");
  478.        } catch(e) {}
  479.        
  480.        prefService.setCharPref("rmFx.abCardItems.version", abCardPrefVersion);       
  481.  
  482.        
  483.     try { rmFx_cardItems = prefService.getComplexValue
  484.             ("rmFx.abCardItems", Components.interfaces.nsISupportsString).data;
  485.     } catch(e) {
  486.         
  487.         if (abCardPrefVersion == "US") {
  488.             rmFx_cardItems = rmFx_cardItemsUS;   // set to US default
  489.                prefService.setCharPref("rmFx.abCardItems.version", "US");
  490.         }
  491.         
  492.         if (abCardPrefVersion == "EU") {
  493.             rmFx_cardItems = rmFx_cardItemsEU;   // set to EU default
  494.                prefService.setCharPref("rmFx.abCardItems.version", "EU");
  495.         }
  496.     }
  497.     return rmFx_cardItems;
  498. }
  499.  
  500.  
  501. function rmFx_writeABcardPref() {
  502. // ------------------------------------------------ WRITE  PREFS
  503.     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  504.             .getService(Components.interfaces.nsIPrefBranch);
  505.  
  506.     var abCardPrefVersion = "US";
  507.     try { abCardPrefVersion = prefService.getCharPref
  508.             ("rmFx.abCardItems.version");
  509.     } catch(e) {
  510.         prefService.setCharPref("rmFx.abCardItems.version", abCardPrefVersion);
  511.     }
  512.     prefService.setCharPref("rmFx.abCardItems", rmFx_cardItems);
  513. }
  514.  
  515.  
  516. /**
  517.  * From the reminderlist open the associated TB/AB card
  518. <br> * This requires the contact was added before from the TB/AB card or list selection
  519. <br> * The reminder has these paramters to define the card:
  520. <br>     reminder.url    {mail address} foo@nowhere.moc
  521. <br>     reminder.extraInfo with 'X-REMINDERFOX-CONTACT:{directory}::{AB title}::{DisplayName})'
  522. <br>   @todo REWORK: with getting a UUID for the card/contact; 
  523.         see bug https://bugzilla.mozilla.org/show_bug.cgi?id=444093 
  524.  
  525.      * @param event -- the selected reminder or todo (only one allowed!)
  526.      * @return opens the TB/AB card 
  527.      */
  528. function rmFxOpenABcard(event) {
  529. //------------------------------------------------------------------------------
  530.     var selectedEvents;
  531.     
  532.     if (event.currentTarget.id == "treechildren-contextmenu-reminder-openABcard")  {
  533.         selectedEvents = getAllSelectedReminders();    // from 'reminder list' context menu
  534.     }
  535.     if (event.currentTarget.id == "treechildren-contextmenu-todo-openABcard")  {
  536.         selectedEvents = getAllSelectedTodos();    // from 'reminder list' context menu
  537.     }
  538.     
  539.     if (selectedEvents.length != 1)  {
  540.         rmFxUtil.PromptAlert("Call TB/AB card only supports one card selection!")            //$$$locale
  541.         return;
  542.     }
  543.     /*----
  544.     let allAddressBooks = abManager.directories; 
  545.     
  546.     while (allAddressBooks.hasMoreElements()) {
  547.           let addressBook = allAddressBooks.getNext();
  548.           if (addressBook instanceof Components.interfaces.nsIAbDirectory) {
  549.  
  550.               rmFxUtil.dump2Console("AB : " + abManager.getDirectory(addressBook.URI).URI 
  551.                       + " " + abManager.getDirectory(addressBook.URI).dirName);
  552. //reminderFox: AB : moz-abmdbdirectory://abook.mab
  553. //reminderFox: AB : moz-abmdbdirectory://abook-1.mab
  554. //reminderFox: AB : moz-abmdbdirectory://history.mab
  555.           
  556.           }
  557.     }
  558.     --------- */
  559.  
  560.  
  561.     // X-REMINDERFOX-CONTACT:moz-abmdbdirectory://abook.mab::Personal Address Book::Werner Niggemann\\nDTSTAMP:20090722T114039
  562.                                                              
  563.     var abManager =
  564.           Components.classes["@mozilla.org/abmanager;1"].
  565.           getService(Components.interfaces.nsIAbManager); 
  566.  
  567.     var exPos = selectedEvents[0].extraInfo.indexOf("X-REMINDERFOX-CONTACT:");
  568.     
  569.     if (exPos != -1) {
  570.  
  571.         var contactInfo = selectedEvents[0].extraInfo.substring(22);
  572.         var contactStr = contactInfo.split("\\n")[0];
  573.         var contactDetails = contactStr.split("::");
  574.         var abURI = contactDetails[0];
  575.         
  576.         if (selectedEvents[0].url != null) {
  577.             var thisMailAdr = selectedEvents[0].url.substring(7);
  578.             var thisCard = abManager.getDirectory(abURI)
  579.                     .cardForEmailAddress(thisMailAdr);
  580.         } else {
  581.                 // search for element as stored with "DisplayName"
  582.                 var thisCard = abManager.getDirectory(abURI)
  583.                     .getCardFromProperty("DisplayName", contactDetails[2], false);
  584.         }
  585.         
  586.         if (thisCard != null) 
  587.             window.openDialog("chrome://messenger/content/addressbook/abEditCardDialog.xul",
  588.                     "",
  589.                     "chrome,resizable=no,modal,titlebar,centerscreen",
  590.                     {abURI:abURI, card:thisCard});
  591.     }
  592. }
  593.     
  594.     /**
  595.      * imported from "Duplicate Contact Manager" by   Marian Steinbach, 2006   
  596.      * normalizeNameString
  597. <br> 
  598.      * Strips some characters from a name so that different spellings (e.g. with and
  599.      * without accents, can be compared. Works case insensitive.
  600.      *
  601.      * @param    String        the string to be normalized
  602.      * @return    String        normalized version of the string
  603.      */
  604. function rmFx_normalizeNameString(str) {
  605. //------------------------------------------------------------------------------
  606.         // remove punctiation
  607.         //str = str.replace(/[\"\-\_\'\.\:\,\;\&\+]+/g, '');
  608.         
  609.         // replace funny letters
  610.         str = str.replace(/[├â┬è├â┬ë├â┬ê├â┬ï├â┬¿├â┬⌐├â┬¬├â┬½├ä┬Æ├ä┬ô├ä┬ö├ä┬ò├ä┬û├ä┬ù├ä┬ÿ├ä┬Ö├ä┬Ü├ä┬¢]/g, 'e');
  611.         str = str.replace(/[├â┬é├â┬ü├â┬Ç├â┬â├â┬à├â┬ó├â┬í├â┬á├â┬ú├â┬Ñ├ä┬Ç├ä┬ü├ä┬é├ä┬â├ä┬ä├ä┬à├ç┬║├ç┬╗]/g, 'a');
  612.         str = str.replace(/[├â┬î├â┬ì├â┬Ä├â┬Å├â┬¼├â┬¡├â┬«├â┬»├ä┬¿├ä┬⌐├ä┬¬├ä┬½├ä┬¼├ä┬¡├ä┬«├ä┬»├ä┬░├ä┬▒]/g, 'i');
  613.         str = str.replace(/[├â┬ò├â┬ÿ├â┬Æ├â┬ô├â┬ö├â┬▓├â┬│├â┬┤├â┬╡├â┬╕├à┬î├à┬ì├à┬Ä├à┬Å├à┬É├à┬æ├ç┬╛├ç┬┐]/g, 'o');
  614.         str = str.replace(/[├â┬Ö├â┬Ü├â┬¢├â┬╣├â┬║├â┬╗├à┬¿├à┬⌐├à┬¬├à┬½├à┬¼├à┬¡├à┬«├à┬»├à┬░├à┬▒├à┬▓├à┬│├å┬í├å┬»├å┬░]/g, 'u');
  615.         str = str.replace(/[├â┬¥├â┬╜├â┬┐├à┬╢├à┬╖├à┬╕]/g, 'y');
  616.         
  617.         str = str.replace(/[├â┬ç├â┬º├ä┬å├ä┬ç├ä┬ê├ä┬ë├ä┬è├ä┬ï├ä┬î├ä┬ì]/g, 'c');
  618.         str = str.replace(/[├â┬É├â┬░├ä┬Ä├ä┬É├ä┬æ]/g, 'd');
  619.         str = str.replace(/[├ä┬£├ä┬¥├ä┬₧├ä┬ƒ├ä┬á├ä┬í├ä┬ó├ä┬ú]/g, 'g');
  620.         str = str.replace(/[├ä┬ñ├ä┬Ñ├ä┬ª├ä┬º]/g, 'h');
  621.         str = str.replace(/[├ä┬┤├ä┬╡]/g, 'j');
  622.         str = str.replace(/[├ä┬╢├ä┬╖├ä┬╕]/g, 'k');
  623.         str = str.replace(/[├ä┬╣├ä┬║├ä┬╗├ä┬╝├ä┬┐├à┬Ç├à┬ü├à┬é]/g, 'l');
  624.         str = str.replace(/[├â┬æ├â┬▒├à┬â├à┬ä├à┬à├à┬å├à┬ç├à┬ê├à┬ë├à┬è├à┬ï]/g, 'n');
  625.         str = str.replace(/[├à┬ö├à┬ò├à┬û├à┬ù├à┬ÿ├à┬Ö]/g, 'r');
  626.         str = str.replace(/[├à┬Ü├à┬¢├à┬£├à┬¥├à┬₧├à┬ƒ├à┬á├à┬í]/g, 's');
  627.         str = str.replace(/[├à┬ó├à┬ú├à┬ñ├à┬Ñ├à┬ª├à┬º]/g, 't');
  628.         str = str.replace(/[├à┬┤├à┬╡]/g, 'w');
  629.         str = str.replace(/[├à┬╣├à┬║├à┬╗├à┬╝├à┬╜├à┬╛]/g, 'z');
  630.         
  631.         // replace ligatures
  632.         str = str.replace(/[├â┬ä├â┬å├â┬ñ├â┬ª├ç┬╝├ç┬╜]/g, 'ae');
  633.         str = str.replace(/[├â┬û├â┬╢├à┬Æ├à┬ô]/g, 'oe');
  634.         str = str.replace(/[├â┬£├â┬╝]/g, 'ue');
  635.         str = str.replace(/[├â┬ƒ]/g, 'ss');
  636.         str = str.replace(/[├ä┬▓├ä┬│]/g, 'ij');
  637.         
  638.         // remove single letters (like initials)
  639.     /*    str = str.replace(/ [A-Za-z0-9] /g, ' ');
  640.         str = str.replace(/^[A-Za-z0-9] /g, '');
  641.         str = str.replace(/ [A-Za-z0-9]$/g, '');
  642.     */    
  643.         // remove multiple white spaces
  644.         str = str.replace(/[\s]{2,}/, ' ');
  645.         
  646.         // remove leading and trailing space
  647.         str = str.replace(/[\s]{2,}/g, ' ');
  648.         str = str.replace(/^[\s]+/, '');
  649.         str = str.replace(/[\s]+$/, '');
  650.         
  651.         str = str.toLowerCase();
  652.         return str;
  653.     }
  654.     
  655.